<!doctype html>
<html lang="zh-CN">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<title>钢链网-个人主页</title>
	<link rel="stylesheet" href="/resource/css/gl_index.css">
	<link rel="stylesheet" href="/resource/css/gl_user.css">

	<script src="/resource/js/jquery-1.11.3.min.js"></script>
	<script src="/resource/js/gl_index.js"></script>
	<script src="/resource/js/webuploader.js"></script>
	<script src="/resource/js/getting-started-qiniu.js"></script>
    <script>
        $(function(){
            $('.down').click(function(){
                var product_id = $(this).attr("res_id");
                $.ajax({
                    url: "/down_new_resource",
                    type: "POST",
                    data: 'down_num=1&product_id='+product_id,
                    async:false,
                    success: function (msg) {

                    }
                });
            });

            var $checkbox = $('input[type="checkbox"]');
            $checkbox.click(function(){
                var product_id = [];
                product(product_id);
                var down_address = [];
                var str_name = "/down_excel_all?filename=";
                var str_id = "&product_id=";
                for (var i = 0; i < $checkbox.length; i++) {
                    if (typeof($checkbox.eq(i).attr('down_address')) != 'undefined') {
                        if($checkbox[i].checked){
                            down_address.push($checkbox.eq(i).attr('down_address'));
                        };
                    }
                };
                if(down_address.length != 0){
                    $.each(down_address,function(index,arr){
                        str_name += ""+arr+",";
                    });
                    $.each(product_id,function(index,arr){
                        str_id += ""+arr+",";
                    });
                    $('.most-down').attr('href',str_name+str_id);
                }
            });

            $('body').after('<div class="follow-cancel popup-cancel"></div>');
            $('.popup-cancel').css({
                'position':'fixed',
                'left':'50%',
                'top':'50%',
                'margin':'-71px 0 0 -165px'
            });
            $('.most-follow').click(function(){
                var product_id = [];
                var cancel = '';
                    cancel = '<div class=\"cancel-p\">';
                    cancel +='<i><img src=\"./resource/img/gl_show_err.png\" alt=""></i>';
                    cancel +='<div class=\"left\">';
                    cancel +='是否取消关注此资源单？<br/>';
                    cancel +='<div class="btn"><a href="javascript:;" class="deter">确定</a>';
                    cancel +='<a href="javascript:;" class="close">取消</a></div>';
                    cancel +='</div><div class=\"cancel-close\"></div></div>';
                product(product_id);
                if(product_id.length != 0){
                    $('.popup-cancel').html(cancel).show();
                    $('.popup-cancel .deter').attr('product_id',product_id);
                }
            });

            $(document).delegate('.popup-cancel .deter','click',function(){
                var product_id = $(this).attr('product_id');
                var page = $('ul.pagination li.active a').html();
                $.ajax({
                    url: "/follow_delete",
                    type: "get",
                    data: "product_id=" + product_id,
                    success: function (msg) {
                        if(msg){
                            $.ajax({
                                url: "/ajax_user_follow",
                                type: "get",
                                data: 'product_id='+product_id,
                                async:false,
                                success: function (msg) {
                                    window.location.href="http://www.ganglianw.com/user_person?page="+page;
                                    if($('.home-bot tbody tr').length == 1){
                                        window.location.href="http://www.ganglianw.com/user_person?page="+(page-1);
                                    }
                                    $('#follow_list').html(msg);
                                }
                            });
                        }
                    }
                })
            });

            function product(product_id){
                for (var i = 0; i < $checkbox.length; i++) {
                    if (typeof($checkbox.eq(i).attr('product_id')) != 'undefined') {
                        if($checkbox[i].checked){
                            product_id.push($checkbox.eq(i).attr('product_id'));
                        };
                    }
                };
            }

        });
    </script>
</head>
<body>
<div class="head">
	@include('common.user_head')
</div>
<div class="user-head">
	<div class="main">
		<div class="logo">
			<a href="/"><img src="/resource/img/logo.png" alt=""></a>
			<div>我的钢链网
				<a href="/">返回首页</a>
			</div>
		</div>
	</div>
</div>	
<div class="user main">
	@include('common.user_menu')
	<div class="user-cont">
		<div class="homepage">
			<div class="home-top">
				<div class="top-info left">
					<div class="til">个人主页</div>
					<div class="file">
						<input type="hidden" id="user_id" value="{{$user_id}}">
						<input type="hidden" id="token" value="{{$token}}">
						<div class="por por-btn" id="filePicker"></div>
						<div class="por por-list" id="fileList">
							@if(!empty($user->avatar))
							<img src="{{$user->avatar}}" alt="">
								@else
							@endif
						</div>
					</div>
					<div class="in">
						<div class="tel">{{$user->mobile}}</div>
						<!-- 未认证 -->
						@if($user->is_supplier==0)
						<div class="company"><a href="/user_seller_join">公司未认证</a></div>
						@else
						<!-- 认证 -->
						<div class="company">北京木投网科技有限公司</div>
						@endif
					</div>
				</div>
				<div class="top-news left">
					<div class="til">消息中心</div>
					<div class="news-num">
						<div class="ne left">
							<a href="/shop_user_news?type=all_message" class="num">{{$system_message}}</a>
							<div class="t t-1">系统通知（条）<i></i></div>
						</div>
						<div class="ne right">
							<a href="/shop_user_news?type=my_message" class="num">{{$my_message}}</a>
							<div class="t t-2">订单通知（条）<i></i></div>
						</div>
					</div>
				</div>
			</div>
			<div class="home-bot">
				<div class="title">
					<div>我的关注</div>
					<div>
						<a href="javascript:;" class="most-down">批量下载</a>
						<a href="javascript:;" class="most-follow">取消关注</a>
					</div>
				</div>
				<div class="table" id="follow_list">
					<table>
						<thead>
							<tr>
								<th width="70px"><input type="checkbox" id="check-all">全选</th>
								<th width="250px">公司名称</th>
                                <th width="340px">主营品类</th>
								<th width="155px">上传者</th>
								<th>操作</th>
							</tr>
						</thead>
						<tbody>
                        @foreach($user_follow as $v)
							<tr>
								<td><div><input type="checkbox" class="res-check" product_id="{{$v->product_id}}" down_address="{{str_replace('\\','/',$v->down_address);}}"></div></td>
								<td><div>{{$v->company}}</div></td>
								<td><div>{{$v->classes}}</div></td>
								<td><div>{{$v->contact_name}}</div></td>
								<td class="last"><div>
									<a href="javascript:;" class="follow Follow succ" product_id="{{$v->product_id}}">取消关注</a>
									<a href="/down_excel?filename={{str_replace('\\','/',$v->down_address);}}" class="down" res_id="{{$v->product_id}}" >下载</a>
								</div></td>
							</tr>
                            @endforeach
						</tbody>
					</table>
				</div>
				{{$user_follow->links()}}
			</div>
		</div>
	</div>
</div>
@include('common.shop_foot')
</body>
</html>